﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FetchNavigationList.aspx.cs" Inherits="FetchNavigationList" %>
<%
    string aid = Request.Params["aid"];

    if (aid == null || aid == "")
    {
%>
    无效信息
<%
    }
    else
    {
        //检查文章的信息
        TreasurerDataContext db = new TreasurerDataContext();
        var q = from aA in db.Articles
                where aA.ID == aid
                select aA;

        if (q.Count() == 0)
        {
%>
    文章被删除，无法找到其父栏目。
<%
        }
        else
        {
            Articles a = q.First();
            Forums f = a.Forum;
            
            //找到其最顶层的栏目
            while (f.Parent != null)
            {
                f = f.Parent;
            }
%>

    <span style="font-size:22px; display:block; padding-left:25px;"><%=f.Name %></span>

<%     
            //判断其最顶层父栏目是否有子栏目，
            //如果有子栏目，则显示其子栏目信息
            if (f.Childs != null)
            {
%>
    <ul>
<%
                foreach (Forums cf in f.Childs)
                {
                    if (cf.ID == a.ForumID)
                    {
%>
            <li><a href="../web/menu2.aspx?fid=<%=cf.ID %>" style="background:url(../web/images/ico_03.jpg) no-repeat;"><strong><%=cf.Name%></strong></a></li>
<%                    
                    }
                    else
                    {
%>
            <li><a href="../web/menu2.aspx?fid=<%=cf.ID %>"><%=cf.Name%></a></li>
<%                    
                    }            
                }
%>
    </ul>
<%                
            }
        }
    }
%>